// 路由配置文件
// 路由api也是组件
import React, { Suspense, lazy } from "react";
import routers from "./routers";
import { Redirect, Route, Switch } from "react-router-dom";
import { getCookie } from "../utils";
const Login = lazy(() => import("../pages/Login"));
const tokenStatus = getCookie("takenStatus");
export default function RouterComp() {
  // if (+tokenStatus !== 1) {
  //   return <Route path="/" component={Login} />;
  // }

  return (
    <Suspense fallback={<div> 加载中...</div>}>
      <Switch>
        <Redirect from="/" to="/home" exact />
        {routers.map((item) => (
          <Route key={item.path} path={item.path} component={item.component} />
        ))}
      </Switch>
    </Suspense>
  );
}
